'''
Author: @zhyy
Date: 2021-01-31 18:43:17
LastEditors: @zhyy
LastEditTime: 2021-01-31 19:12:16
'''

from cerberus import Validator
from app.validators.error_handler import ErrorHandler
class UserVilditor():
    @staticmethod
    def user_validator():
        rules={
            'name': {
                'type': 'string',
                'minlength': 6,
                'maxlength': 18
            },
            'age': {
                'type': 'integer',
                'min': 18,
                'max': 65},
            "phone": {
                "type": "string",
                "minlength": 11,
                "maxlength": 11,
                "regex": "^1[3,4,5,7,8,9][0-9]{9}$"
            },
            "email": {
                "type": "string",
                "minlength": 8,
                "maxlength": 255,
                "required": True,
                "regex": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$"
            }
        }
        v = Validator(
        rules, error_handler=ErrorHandler(custom_messages=error_msg))

